#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<string.h>
#include<sys/wait.h>
#include<fcntl.h>
#include<sys/stat.h>


int main()
{
int pipefd[2];
int ret=pipe(pipefd);
if(ret<0)
{
perror("pipe");
return -1;
}
pid_t pid1=fork()
if(pid1==0)
{
close(pipefd[0]);
dup2(pipefd[1],1);
execlp("ps","ps","-ef",NULL);
exit(-1);
}


pid_t pid2=fork();
if(pid2==0)
{
close(pipefd[1]);
dup2(pipefd[0],0);
execlp("grep","grep","pipe",NULL);
exit(-1);

}
close(pipefd[0]);
close(pipefd[1]);
wait(NULL);
wait(NULL);

return 0;
}
